//
//  KLCollectionGoodTableViewCell.m
//  KunLun
//
//  Created by Mac on 2017/11/28.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "KLShopCartTableViewCell.h"
@interface KLShopCartTableViewCell()
@property(nonatomic, strong) UIImageView                     *iconImageView;
@property(nonatomic, strong) STLabel                     *titleLable;
@property(nonatomic, strong) STLabel                     *numLable;
@property(nonatomic, strong) STLabel                     *moneyLable;


@end
@implementation KLShopCartTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 130;
}
#pragma mark --subView
- (void)configSubView{
    
    self.chosedButton = [[STButton alloc] initWithFrame:CGRectMake(10, 0, 44, 44)
                                                  title:nil
                                             titleColor:nil
                                              titleFont:0
                                           cornerRadius:0
                                        backgroundColor:nil
                                        backgroundImage:nil
                                                  image:[UIImage imageNamed:@"购物未选中"]];
    
    [self.chosedButton setImage:[UIImage imageNamed:@"购物选中"] forState:UIControlStateSelected];
    self.chosedButton.centerY = [KLShopCartTableViewCell cellHeight]/2;
    [self addSubview:self.chosedButton];
    
    
    self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.chosedButton.right , 10, 80, 100)];
    self.iconImageView.image = [UIImage imageNamed:@"09"];
    [self addSubview:self.iconImageView];
    
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 5, self.iconImageView.top + 3, UIScreenWidth - 20 - self.iconImageView.right, 40)
                                                text:@"房价开始砥砺奋进克鲁塞德九分裤的手机蓝色的见风使舵"
                                           textColor:KL_secendTextColor
                                                font:14
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    self.titleLable.numberOfLines = 0;
    [self addSubview:self.titleLable];
    
    self.numLable = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 5, self.titleLable.bottom + 3, 150, 20)
                                              text:@"共1件"
                                         textColor:KL_secendTextColor
                                              font:12
                                       isSizetoFit:NO
                                     textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.numLable];
    
    self.moneyLable = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 5, self.numLable.bottom + 3, 150, 20)
                                                text:@"120"
                                           textColor:KL_redColor
                                                font:14
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentRight];
    self.moneyLable.right = UIScreenWidth - 10;
    self.moneyLable.bottom = self.iconImageView.bottom;
    [self addSubview:self.moneyLable];
    

    
}
- (void)setGoodModel:(KLGoodModel *)goodModel{
    _goodModel = goodModel;
    
    self.titleLable.text = goodModel.goods_name;

    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:goodModel.exhibition_map] completed:nil];
    
    
    self.numLable.text = [NSString stringWithFormat:@"数量:%@",goodModel.number];
    
    
    self.moneyLable.text = [NSString stringWithFormat:@"￥%0.2f",goodModel.price.floatValue * goodModel.number.integerValue];
    
    self.chosedButton.selected = goodModel.selected;
}
@end

